<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>

<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title></title>
<style type="text/css">
body {
	background-image: url(images/yiyuan.jpg);
}

form {
	width: 500px;
	overflow: hidden;
	margin: 50px auto;
}

div {
	line-height: 40px;
}

input {
	width: 250px;
	padding-left: 10px;
	height: 30px;
	line-height: 30px;
	color: #333;
	font-size: 14px;
	border: 1px solid #666;
	outline: none;
	margin-bottom: 10px;
	display: inline-block;
}

span {
	display: inline-block;
	float: left;
}

.submit {
	width: 120px;
	background: #269ABC;
	color: #fff;
	margin-left: 70px;
	cursor: pointer;
}
</style>
</head>
<body>
	<form action="doctor?action=add" enctype="multipart/form-data"  method="post" class="form"
		onsubmit="return check(this)">		
		<div>
			<span>医院编号：</span><input type="text" name="hospitalno"
				id="hospitalno" pattern="[0-9]+" placeholder="医院编号" required /><br />
		</div>
		<div>
			<span>科室编号：</span><input type="text" name="adninno" id="adninno"
				pattern="[0-9]+" placeholder="科室编号" required /><br />
		</div>
		<div>
			<span>医师姓名：</span><input type="text" name="name" id="name"
				placeholder="医师姓名" /><br />
		</div>
		<div>
			<span>医师性别：</span><select id="sex" name="sex">
				<option>男</option>
				<option>女</option>
			</select><br />
		</div>
		<div>
			<span>医师年龄：</span><input type="text" name="age" id="age"
				placeholder="医师年龄" required /><br />
		</div>
		<div>
			<span>联系方式：</span><input type="text" name="phone" id="phone"
				placeholder="手机号" /><br />
		</div>
		<div>
			<span>医师职称：</span><input type="text" name="appellation"
				id="appellation" placeholder="医师职称" /><br />
		</div>
		<div>
			<span>邮箱地址：</span><input type="email" name="email" id="email"
				placeholder="邮箱地址" /><br />
		</div>
		<div>
			<span>个人简介：</span>
			<textarea name="brief" id="brief"></textarea>
			<br />
		</div>
		<div>
			<span>个人图片：</span><input type="file" name="img" id="img"
				placeholder="" /><br />
		</div>
		<input type="submit" value="提交" class="submit" />
	</form>
	<script type="text/javascript">
		function check() {
			//			姓名
			var name = document.getElementById("name");
			if (name.value == '') {
				alert('姓名不能为空');
				name.focus();
				return false;
			} else {
				var vname = (/^[a-zA-Z\u4e00-\u9fa5]{2,10}$/);
				if (!vname.test(name.value)) {
					alert('姓名2-10个字，只能是中文或英文');
					name.focus();
					return false;
				}
			}

			//			电话
			var phone = document.getElementById('phone');
			if (phone.value == '') {
				alert('电话不能为空');
				phone.focus();
				return false;
			} else {
				var phone_reg = /^13[0-9]{1}[0-9]{8}$|15[0-9]{1}[0-9]{8}$|18[0-9]{1}[0-9]{8}|17[0-9]{1}[0-9]{8}$|14[0-9]{1}[0-9]{8}/;
				var tel_reg = /^([0-9]{3,4}-)?[0-9]{7,8}$/;
				if (!phone_reg.test(phone.value) && !tel_reg.test(phone.value)) {
					alert('手机或电话号码格式不正确。如果是固定电话，必须形如(xxxx-xxxxxxxx)');
					phone.focus();
					return false;
				}
			}

			//密码
			var pwd1 = document.getElementById('pwd1');
			if (pwd1.value == '') {
				alert('密码不能为空');
				pwd1.focus();
				return false;
			} else {
				var vpwd = /^[A-Za-z0-9]+$/;
				if (!vpwd.test(pwd1.value)) {
					alert('密码错误，密码由数字和字母组成');
					pwd1.focus();
					return false;
				} else {
					if (pwd1.value.length < 6) {
						alert('密码不能少于6位');
						pwd1.focus();
						return false;
					}
				}
			}
			//			验证密码
			var pwd2 = document.getElementById('pwd2');
			if (!(pwd2.value == pwd1.value)) {
				alert('确认密码与第一次输入不同，请重新输入');
				pwd2.focus();
				return false;
			}

			//			邮箱
			var email = document.getElementById('email');
			if (email.value == '') {
				alert('邮箱不能为空');
				email.focus();
				return false;
			} else {
				var vemail = /^[0-9a-zA-Z]+(?:[\_\.\-][a-z0-9\-]+)*@[a-zA-Z0-9]+(?:[-.][a-zA-Z0-9]+)*\.[a-zA-Z]+$/i;
				if (!vemail.test(email.value)) {
					alert('邮箱格式错误');
					email.focus();
					return false;
				}
			}
			//			地址
			var address = document.getElementById('address');
			if (address.value == '') {
				alert('地址不能为空');
				address.focus();
				return false;
			} else {
				if (address.value.length < 8) {
					alert('不能少于8个字');
					address.focus();
					return false;
				}
			}

		}

		function validateFeeling(input) {
			if (input.value() == "") {
				input.setCustomValidity('请填写完整信息');
				return false;
			}
		}
	</script>
</body>
</html>
